<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <asset:stylesheet href="css.css"/>
    <asset:stylesheet href="themes/default/easyui.css"/>
    <asset:stylesheet href="themes/icon.css"/>
    <asset:javascript src="jquery.min.js"/>
    <asset:javascript src="jquery.form.min.js"/>
    <asset:javascript src="jquery.easyui.min.js"/>
    <asset:javascript src="admin/Index.js"/>

    <title></title>
</head>

<body>


<table id="dg" class="easyui-datagrid"
       data-options="width:'100%',url:'dtxm_json',showFooter:true,selectOnCheck:true,toolbar:toolbar,fit:true,singleSelect:true,pagination:true,pageList: [20,40,60,80,100,200,500], loadMsg:'数据加载中......请稍后'">
    <thead>
    <tr>
        <th data-options="field:'ID',checkbox:true"></th>
        <th  data-options="field:'PROJECT_NAME'">项目名称</th>
        <th  data-options="field:'ISENABLE'">是否启用</th>

    </tr>
    </thead>
</table>


<div id="dlg_xm" class="easyui-dialog" title="答题项目添加" data-options="iconCls:'icon-save',closed:true" style="width:30%; height:50%;">
        <g:form name="createXm"  controller="admin" action="dt_xmadd" method="post">
          <table  style="width:100%; height: 100%;" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
        <thead>
        <tr>
            <th height="35" bgcolor="#FFFFFF">项目名称</th>
            <th bgcolor="#FFFFFF">是否启用</th>
        </tr>
        </thead>
        <tbody>
        <tr>

            <td height="35" align="center" bgcolor="#FFFFFF"><input type="text" name="projectName" id="projectName"/></td>
            <td align="center" bgcolor="#FFFFFF"><input type="radio" name="isenable"  id="qy" value="0"  class="dataOracle"/>
                启用
                <input type="radio" name="isenable" value="1" id="ty"  class="dataOracle"/>
                停用</td>
        </tr>
        <tr>
            <td height="35" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" name="qd" id="qd" value="确 定"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="gb" id="bg" value="关 闭" onclick="dt_xm_gb()"/></td>
        </tr>
        </tbody>
    </table>
        </g:form>
</div>

</body>
</html>
<script type="text/javascript" charset="utf-8">
    var toolbar = [{
        text:'添加项目',
        iconCls:'icon-add',
        handler:function(){
           //事件响应区
            $('#dlg_xm').dialog('open');
        }
    },'-',{

        text:'修改项目',
        iconCls:'icon-edit',
        handler:function() {

            var row = $('#dg').datagrid('getSelected');
            $.ajax({
                type: "GET",
                url: "Edit_xm",
                cache: false,
                data: {id: row.ID, date: new Date()},
                async: false,
                success: function (msg) {
                   // alert(msg);
                    $("#createXm").append("<input type=\"hidden\" id=\"id\" name=\"id\" value=\"\">");
                    $("#createXm").attr("action", "update");
                    $('#dlg_xm').dialog('open');
                    $.each(msg, function (i, n) {
                       // alert(i+'----'+n);
                        $("#" + i).val(n);
                        if($("#qy").val() == "0"){
                            $("#qy").attr("checked","checked");
                    }
                        if($("#ty").val() == "1"){
                            $("#ty").attr("checked","checked");
                        }
                    });
                }
            });
        }
        },'-',{
        text:'删除项目',
        iconCls:'icon-remove',
        handler:function() {
            var row = $('#dg').datagrid('getSelected');
            $.ajax({
                type: "POST",
                url: "del_xm",
                cache: false,
                data: { id:row.ID, date: new Date()},
                async: false,
                success: function (msg) {
                    if (msg == "true"){
                        alert("项目删除成功！");
                        document.location.reload();
                    }

                }
            });



        }
        },'-',{
        text:'刷新页面',
        iconCls:'icon-reload',
        handler:function() {
            //事件响应区
            document.location.reload();
        }

    }];

</script>